//
//  ViewController.swift
//  barrier-Swift
//
//  Created by 李煜 on 2024/5/21.
//

import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let customConcurrentQueue = DispatchQueue(label: "自定义并发队列", attributes: .concurrent)
        customConcurrentQueue.async {
            for i in 1...1000 {
                debugPrint("--download1:\(i)",Thread.current)
            }
        }
        customConcurrentQueue.async {
            for i in 1...1000 {
                debugPrint("--download2:\(i)",Thread.current)
            }
        }
        customConcurrentQueue.async(group: nil, qos: .default, flags: .barrier) {
            debugPrint("---------barrier-----------------")
        }
        customConcurrentQueue.async {
            for i in 1...1000 {
                debugPrint("--download3:\(i)",Thread.current)
            }
        }
    }
}
